#ifndef _DICT_H_
#define _DICT_H

/*
Inspired by: 
http://pine.cs.yale.edu/pinewiki/C/GenericContainers
*/

typedef struct Dict_struct *Dict;

/* Provides operations for working with keys or values */
struct Dictinfo_struct {
    /* hash function */
    unsigned long (*hash)(const void *datum, void *arg);	
    /* returns nonzero if *datum1 == *datum2 */
    int (*equal)(const void *datum1, const void *datum2, void *arg);
    /* make a copy of datum that will survive changes to original */
    void *(*copy)(const void *datum, void *arg); 
   /* free a copy */
    void (*free)(void *datum, void *arg);
   /* extra argument, to allow further specialization */
    void *arg;
};

typedef struct Dictinfo_struct * Dictinfo;

/* create a new dictionary with given key and value operations */
/* Note: value_ops.hash and value_ops.equal are not used. */
Dict dict_make(Dictinfo key_ops, Dictinfo value_ops);

/* free a dictionary and all the space it contains */
/* This will call the appropriate delete function for all keys and */
/* values. */
void dict_free(Dict d);

/* Set dict[key] = value. */
/* Both key and value are copied internally. */
/* If data is the null pointer, remove dict[key]. */
void dict_set(Dict d, const void *key, const void *value);

/* Return dict[key], or null if dict[key] has not been set. */
const void *dict_get(Dict d, const void *key);




#endif
